package com.lanou3g.ptp.role.service.impl;

import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.lanou3g.ptp.entity.Role;
import com.lanou3g.ptp.role.RoleService;
import com.lanou3g.ptp.role.mapper.RoleMapper;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    private RoleMapper roleMapper;
//    增加一个role
    @Override
    public void addRole(Role role) {
        roleMapper.addRole(role);
    }
//  通过id删除
    @Override
    public void deleteById(Long id) {
        roleMapper.deleteById(id);
    }
//  通过id修改
    @Override
    public void updateById(Role role) {
        roleMapper.updateById(role);
    }
//  查找全部role
    @Override
    public List<Role> findAll(Integer page, Integer size) {
        Page<Object> objects = PageHelper.startPage(page, size);
        List<Role> rolesAll = roleMapper.findAll();
        return rolesAll;
    }
//  通过id查找
    @Override
    public List<Role> findById(Long id) {
       List<Role> roleList = roleMapper.findById(id);
       return roleList;
    }
}
